#ifndef __SQLDELAYTHREAD_H
#define __SQLDELAYTHREAD_H

#include "ace/Thread_Mutex.h"
#include "LockedQueue.h"
#include "Threading.h"


class Database;
class SqlOperation;
class SqlConnection;

class SqlDelayThread : public ACE_Based::Runnable
{
typedef ACE_Based::LockedQueue<SqlOperation*, ACE_Thread_Mutex> SqlQueue;

public:
							SqlDelayThread(Database* db, SqlConnection* conn);
							~SqlDelayThread();

public:///    
    bool					Delay(SqlOperation* sql) { m_sqlQueue.add(sql); return true; }	///< Put sql statement to delay queue

    virtual void			Stop();											///< Stop event
    virtual void			run();											///< Main Thread loop

private:
	void					ProcessRequests();								//process all enqueued requests

private:
	SqlQueue				m_sqlQueue;										///< Queue of SQL statements
	Database*				m_dbEngine;										///< Pointer to used Database engine
	SqlConnection *			m_dbConnection;									 ///< Pointer to DB connection
	volatile bool			m_running;

	
};
#endif																		//__SQLDELAYTHREAD_H
